package com.chen.service.type;

import com.chen.dao.TypeMapper;
import com.chen.pojo.Type;
import com.chen.vo.TypeVo;

import java.util.List;

public class TypeServiceImpl implements TypeService {
    private TypeMapper typeMapper;

    public void setTypeMapper(TypeMapper typeMapper) {
        this.typeMapper = typeMapper;
    }

    public Type queryTypeById(int typeId) {
        return typeMapper.queryTypeById(typeId);
    }

    public List<Type> queryAllType(TypeVo typeVo) {
        return typeMapper.queryAllType(typeVo);
    }

    public int addCourtType(Type type) {
        //可用球场数量默认全部都是 球场数量
        type.setTypeAvailableNum(type.getTypeCourtNum());
        type.setTypeReservedNum(0);
        return typeMapper.addCourtType(type);
    }

    public int updateCourtType(Type type) {
        //已预约人数默认是0
        type.setTypeReservedNum(0);
        //可用球场数量默认全部都是 球场数量
        type.setTypeAvailableNum(type.getTypeCourtNum());
        return typeMapper.updateCourtType(type);
    }

    public int deleteById(Integer typeId) {
        return typeMapper.deleteById(typeId);
    }
}
